package com.admin.service;

import com.admin.bean.GoodSoftwareType;
import com.admin.dbdao.GoodSoftwareTypeDao;
import com.data.util.CheckDataUtils;
import com.data.util.DatabaseIdUtils;
import com.data.util.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 精选软件类别服务层
 *
 * @author:HingLo
 * @create 2017-09-30 16:45
 **/
@Service
public class GoodSoftwareTypeService {
    @Autowired
    private GoodSoftwareTypeDao goodSoftwareTypeDao;


    public List<?> findAllGoodSoftwareTypeService() {
        return goodSoftwareTypeDao.findAllGoodSoftwareTypeDao();
    }

    public boolean submitGoodSoftwareAddAdminService(GoodSoftwareType goodSoftwareType, String date) {
        date = date.trim();
        if (!CheckDataUtils.stringUtilsID(goodSoftwareType.getId())) {
            goodSoftwareType.setId(DatabaseIdUtils.getDataIdOne());
        }
        goodSoftwareType.setCtime(new Date());
        goodSoftwareType.setEndtime(DateUtils.stringToDate(date));
        return goodSoftwareTypeDao.saveMassageDao(goodSoftwareType);
    }

    public boolean delGoodSoftwareAdminService(String id) {
        if (CheckDataUtils.stringUtilsID(id)) {
            id = id.trim();
            return goodSoftwareTypeDao.updateGoodSoftwareAdminDao(id);
        }
        return false;
    }

    public GoodSoftwareType lookGoodSoftwareIconService(String id) {
        id = id.trim();
        List<GoodSoftwareType> list = goodSoftwareTypeDao.lookGoodSoftwareIconDao(id);
        return list.isEmpty() ? null : list.get(0);
    }
}
